#ifndef _CALC_GAME_H_20181123_
#define _CALC_GAME_H_20181123_

#include "event_cpp/loop.h"
#include "event_cpp/timer_event.h"
#include "event_cpp/fd_event.h"

using namespace lumi::event_cpp;

class Game {
  public:
    Game();
    void init(WeakPtr<Loop> wp_loop);

  protected:
    void onStartGame();
    void askQuestion();
    void on30SecReach();
    void on20SecReach();
    void on10SecReach();
    void onStdinReadable(short event);

  private:
    WeakPtr<Loop> wp_loop_;

    TimerEventSptr sp_start_timer_;
    TimerEventSptr sp_30sec_timer_;
    TimerEventSptr sp_20sec_timer_;
    TimerEventSptr sp_10sec_timer_;
    FdEventSptr sp_stdin_read_ev_;

    int start_countdown_;
    int right_answer_;
    int remain_question_number_;
    time_t start_tstamp_;
    bool user_start_;
};

#endif //_CALC_GAME_H_20181123_
